<?php
/**
 * @annotate 后台企业管理
 * @group   Admin/Haiyin
 * @author   yachtxiao <fuck@fackyou.org>
 */
class ResumeAction extends BaseAction {
	public function resume_list(){
		$timetoday = strtotime(date("Y-m-d",time()));//今天0点的时间点
		$timeyestoday = $timetoday - 3600*24;//今天0点的时间点，两个值之间即为昨
		$day = $_GET['day'];
		if($day=='today'){
			$map['ctime'] = array('egt',$timetoday);
		}elseif($day=='yesterday'){
			$map['ctime'] = array('between',$timeyestoday.','.$timetoday);
		}
		 if ($this->isPost()){
		 	$name = $_POST['name'];
		 	$map['truename'] = array('like',$name.'%');
		 }
		$list = D('member_info')->where($map)->order('ctime desc')->findPage(20);
		foreach ($list['data'] as $k => &$v) {
			$v['pic'] = get_img_url($v['face']);
			$v['exper'] =  D('exper')->where(array('uid'=>$v['uid'],'is_del'=>0))->select();
			$v['resume'] = D('resume')->where(array('uid'=>$v['uid']))->find();
		}
		$this->assign("list",$list);
		$this->display();
	}

	public function send_list(){
		$timetoday = strtotime(date("Y-m-d",time()));//今天0点的时间点
		$day = $_GET['day'];
		if($day=='today'){
			$map['send_time'] = array('egt',$timetoday);
		}
		$list = D('send_resume')->where($map)->order('send_time desc')->findPage(20);
		foreach($list['data'] as $k=>&$v){
			$v['resume'] =  D('resume')->where(array('resume_id'=>$v['resume_id']))->find();
			$v['info'] =  D('member_info')->where(array('uid'=>$v['resume']['uid']))->find();
			$v['exper'] =  D('exper')->where(array('uid'=>$v['resume']['uid'],'is_del'=>0))->select();
			$v['info']['pic'] = get_img_url($v['info']['face']);
			$v['hiring'] = D('hiring')->where(array('hiring_id'=>$v['hiring_id']))->find();
			$v['hiring_info'] = D('hiring_info')->where(array('hiring_id'=>$v['hiring_id']))->find();
			$m['sid'] = array('in',$v['hiring']['workplace']);
			$store = D('store')->where($m)->select();
			$data['cid'] = $v['hiring']['cid'];
			$data['is_del'] = 0;
			$v['com_info'] = D('company_info')->where($data)->find();
			$age = explode(',',$v['hiring_info']['age']);
			$v['hiring_info']['age_start'] = $age[0];
			$v['hiring_info']['age_end'] = $age[1];
			$v['hiring']['workplace']=D('Hiring')->foreach_workplace($store);
		}
		$this->assign("list",$list);
		$this->display();
	}

	public function del_resume(){
		$map['info_id'] = $_POST['id'];
		$data['is_del'] = 1;
		$da = D('member_info')->where($map)->save($data);
		if($da){
			$this->ajaxReturn('','success',1);
		}else{
			$this->ajaxReturn('','error',0);    
		} 
	}
	 public function send(){
	 	$list = D('send')->order('ctime desc')->findPage(20);
	 	foreach ($list['data'] as $k => &$v) {
	 		if($v['status'] == 0){
	 			$v['truename'] = D('member_info')->where('uid ='.$v['uid'])->getField('truename');
	 		}else{
	 			$v['truename'] = D('company')->where('cid ='.$v['uid'])->getField('company_name');
	 		}
	 		
	 		$v['resume_name'] = D('member_info')->where('info_id ='.$v['info_id'])->getField('truename');
	 	}
	 	$this->assign('list',$list);
	 	$this->display();
	 }
}
?>